package cn.nextProject.controller;

import cn.nextProject.entity.FormConfig;
import cn.nextProject.entity.Result;
import cn.nextProject.mapper.FormConfigMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class FormConfigController {

    @Autowired
    private FormConfigMapper formConfigMapper;

    @PostMapping("/insertFormConfig")
    public Result<?> insertFormConfig(@RequestBody FormConfig formConfig){
        if (ObjectUtils.isEmpty(formConfig)){
             return new Result<>().fail("参数不能为空");
        }
        formConfigMapper.insert(formConfig);
        return new Result<>().success("新增成功",null);
    }

    @PostMapping("/findFormConfig")
     public Result<?> findFormConfig(@RequestBody FormConfig formConfig){
        if (ObjectUtils.isEmpty(formConfig)){
            return new Result<>().fail("参数不能为空");
        }
        return new Result<>().success("查询成功",formConfigMapper.findConfig(formConfig));
    }




}
